export default {
  type: 'page',
  data: {
    name: '我是用户管理页面',
  },
  body: [
    {
      type: 'crud',
      name: 'crud',
      api: {
        url: '/api/user/getUserList',
        method: 'post',
        data: {
          nickName: '$nickName',
          userName: '$userName',
          type: '$type',
          page: '${page}',
          pageSize: '${perPage}',
        },
      },
      syncLocation: false,
      showIndex: true,
      headerToolbar: [
        {
          label: '新增',
          type: 'button',
          actionType: 'dialog',
          level: 'primary',
          size: 'sm',
          icon: 'fa fa-plus',
          dialog: {
            title: '新增表单',
            body: {
              type: 'form',
              api: 'post:/amis/api/mock2/sample',
              body: [
                {
                  type: 'input-text',
                  name: 'nickName',
                  label: '昵称',
                },
                {
                  type: 'input-text',
                  name: 'browser',
                  label: 'Browser',
                },
              ],
            },
          },
        },
      ],
      autoGenerateFilter: {
        columnsNum: 5,
        showBtnToolbar: false,
      },
      columns: [
        {
          name: 'avatar',
          type: 'image',
          label: '头像',
          image: {
            width: '50px',
          },
        },
        {
          name: 'nickName',
          label: '昵称',
          searchable: true,
        },
        {
          name: 'userName',
          label: '账号',
          searchable: true,
        },
        {
          name: 'type',
          label: '用户所属平台',
          type: 'mapping',
          searchable: {
            type: 'select',
            clearable: true,
            value: '',
            options: [
              {
                label: '全部',
                value: '',
              },
              {
                label: '客户端用户',
                value: 'client_user',
              },
              {
                label: '管理员用户',
                value: 'admin_user',
              },
            ],
          },
          map: {
            client_user: '客户端用户',
            admin_user: '管理员用户',
          },
        },
        {
          name: 'isAdmin',
          label: '账号类型',
          type: 'mapping',
          map: {
            true: "<span class='label label-info'>超级管理员</span>",
            false: "<span class='label label-success'>普通用户</span>",
          },
        },
        {
          name: 'gender',
          label: '性别',
          type: 'mapping',
          map: {
            1: '<span class="text-primary">男</span>',
            0: '<span class="text-danger">女</span>',
          },
        },
        {
          type: 'operation',
          label: '操作',
          buttons: [
            {
              label: '详情',
              type: 'button',
              level: 'link',
              actionType: 'dialog',
              dialog: {
                title: '查看详情',
                body: {
                  type: 'form',
                  body: [
                    {
                      type: 'input-text',
                      name: 'engine',
                      label: 'Engine',
                    },
                    {
                      type: 'input-text',
                      name: 'browser',
                      label: 'Browser',
                    },
                    {
                      type: 'input-text',
                      name: 'platform',
                      label: 'platform',
                    },
                    {
                      type: 'input-text',
                      name: 'version',
                      label: 'version',
                    },
                    {
                      type: 'control',
                      label: 'grade',
                      body: {
                        type: 'tag',
                        label: '${grade}',
                        displayMode: 'normal',
                        color: 'active',
                      },
                    },
                  ],
                },
              },
            },
            {
              label: '删除',
              type: 'button',
              level: 'link',
              className: 'text-danger',
              actionType: 'ajax',
              confirmText: '是否要删除【$nickName】？',
              confirmTitle: '删除用户',
              api: {
                url: '/api/user/deleteUser?id=$id',
                method: 'GET',
              },
              reload: 'crud',
            },
          ],
        },
      ],
    },
  ],
};
